namespace C1.Win.C1FlexGrid.Util.Styles
{
    using C1.Win.C1FlexGrid.Util;
    using System;
    using System.Drawing;

    internal class BorderCompound : Border
    {
        internal Border _inner;
        internal Border _outer;

        protected BorderCompound()
        {
        }

        public BorderCompound(Border outer, Border inner)
        {
            this._outer = outer;
            this._inner = inner;
        }

        public void AddInner(Border b)
        {
            this._inner = (this._inner == null) ? b : new BorderCompound(this._inner, b);
        }

        public void AddOuter(Border b)
        {
            this._outer = (this._outer == null) ? b : new BorderCompound(b, this._outer);
        }

        public override Margins GetInsets()
        {
            Margins margins = this._outer.GetInsets();
            Margins margins2 = this._inner.GetInsets();
            return new Margins(margins.Left + margins2.Left, margins.Right + margins2.Right, margins.Top + margins2.Top, margins.Bottom + margins2.Bottom);
        }

        public override void Render(Graphics g, Rectangle r)
        {
            this._outer.Render(g, r);
            r = this._outer.InnerRect(r);
            this._inner.Render(g, r);
        }
    }
}

